package com.unis.datapush.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.unis.datapush.service.ZhxqService;
import com.unis.datapush.util.CopyUtil;
import com.unis.datapush.util.R;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
@Api(tags = {"ZhxqController"},value = "智慧小区",description = "智慧小区相关接口说明")
public class ZhxqController {

    @Autowired
    private ZhxqService zhxqService;


   /* @GetMapping("/getYswdjList")
    @ApiOperation(value = "疑似未登记实有人口")
    public R getYswdjList(HttpServletRequest request,
                          @ApiParam(name = "xqxxbz",value = "小区信息标识",required = true)
                                                 @RequestParam String xqxxbz){
        Map<String, Object> map = CopyUtil.copyToMap(request);
        return R.ok().put("data",zhxqService.getYswdjList(map));
    }*/

    @GetMapping("/getYswdjList")
    @ApiOperation(value = "疑似未登记实有人口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示数量"),
            @ApiImplicitParam(name = "xqxxbz",value = "小区消息标识")
    })
    public R getYswdjList(HttpServletRequest request,@RequestParam int pageNum,
                          @RequestParam int pageSize,@RequestParam String xqxxbz){
        PageHelper.startPage(pageNum,pageSize);
        Map<String, Object> map = CopyUtil.copyToMap(request);
        PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(zhxqService.getYswdjList(map));
        return R.ok().put("data",pageInfo);
    }

    @GetMapping("/getYswdjCount")
    @ApiOperation(value = "疑似未登记实有人口数量")
    public R getYswdjCount(HttpServletRequest request, @RequestParam String xqxxbz){
        Map<String, Object> map = CopyUtil.copyToMap(request);
        return R.ok().put("data",zhxqService.getYswdjCount(map));
    }
}
